{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "import necessary libraries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pickle\n",
    "\n",
    "from keras.models import Sequential\n",
    "from keras.layers import Dense\n",
    "from keras.layers import LSTM\n",
    "from keras.layers import Dropout"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "load the dataset, we train our RNN on three separate time series, with their individual labels"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "radarData_fn_list = ['data/072819_ag_onNotOn/f_data-2019-07-28_21-44-17.102820_ag_onNotOn_rnn/f_data.p',\n",
    "                     'data/072819_zl_onNotOn/f_data-2019-07-28_22-11-01.258054_zl_onNotOn_rnn/f_data.p',\n",
    "                     'f_data-2019-07-29_11-40-44.161380_zy_onNotOn/f_data.p']\n",
    "groundTruth_fn = [''\n",
    "                  ''\n",
    "                  '']\n",
    "\n",
    "radarData_list = []\n",
    "for radarData_fn in radarData_fn_list:\n",
    "    radarData_list.append(pickle.load(open(radarData_fn, 'rb')))\n",
    "groundTruth = pickle.load(open(groundTruth_fn, 'rb'))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "build the network"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "timestep = 50\n",
    "\n",
    "# Initialising the RNN\n",
    "regressiveClassifier = Sequential()\n",
    "\n",
    "# batch size = 3337, num_timestep = 100,\n",
    "# input shape = num_timestep * length of the flattened, padded data at each timestep\n",
    "regressiveClassifier.add(LSTM(units=50, return_sequences=True, input_shape=(timestep, 400)))\n",
    "regressiveClassifier.add(Dropout(0.2))\n",
    "\n",
    "regressiveClassifier.add(LSTM(units=50, return_sequences=True))\n",
    "regressiveClassifier.add(Dropout(0.2))\n",
    "\n",
    "regressiveClassifier.add(LSTM(units=50, return_sequences=False))\n",
    "regressiveClassifier.add(Dropout(0.2))\n",
    "\n",
    "# dense layer\n",
    "# sigmoid for binary output\n",
    "regressiveClassifier.add(Dense(1, activation='sigmoid'))\n",
    "\n",
    "regressiveClassifier.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "kernelspec": {
   "name": "python3",
   "language": "python",
   "display_name": "Python 3"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}